package tuding.android.bigplanettracks;

import org.acra.*;
import org.acra.annotation.*;
import tuding.android.bigplanettracks.util.Preferences;
import android.app.Application;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
/**
 * Central Application module for Tuding
 *
 */

@ReportsCrashes(formKey = "", // will not be used
        mailTo = "tudinger@gmail.com",
        customReportContent = { ReportField.ANDROID_VERSION, ReportField.PHONE_MODEL, ReportField.CUSTOM_DATA, ReportField.STACK_TRACE, ReportField.LOGCAT },                
        mode = ReportingInteractionMode.NOTIFICATION,
        resNotifTickerText = R.string.crash_notif_ticker_text,
        resNotifTitle = R.string.crash_notif_title,
        resNotifText = R.string.crash_notif_text,
        resNotifIcon = android.R.drawable.stat_notify_error, // optional. default is a warning sign
        resDialogText = R.string.crash_dialog_text,
        resDialogIcon = android.R.drawable.ic_dialog_info, //optional. default is a warning sign
        resDialogTitle = R.string.crash_dialog_title, // optional. default is your application name
        resDialogCommentPrompt = R.string.crash_dialog_comment_prompt, // optional. when defined, adds a user text field input with this text resource as a label
        resDialogOkToast = R.string.crash_dialog_ok_toast, // optional. displays a Toast message when the user accepts to send a report.

        resToastText = R.string.crash_toast_text)


public class TudingerApp extends Application {

	public static boolean isDemo = false;
	private  String m_versionName;
	private  int m_versionCode;
;

	private static TudingerApp application;
	public TudingerApp() {
		super();
	}

	@Override
	public void onCreate() {
	    _parseVersion();
	    application = this;
		Preferences.init(this);
		ACRA.init(this);
	}
	
	/**
	 * singleton to get the TudingerApp instance
	 * @return
	 */
	public static TudingerApp getApplication() {
        return application;
    }
	
	   /**
     * 
     * @return the version String of this app
     */
    public String getVersionName() {
        return m_versionName;
    }
    
    /**
     * 
     * @return get the version code of this app
     */
    public int getVersionCode () {
        return m_versionCode;
    }
    /**
     * parse the app version from the manifest.xml 
     */
    private void _parseVersion() {
        try {
            PackageInfo pInfo = this.getPackageManager().getPackageInfo(
                    this.getPackageName(), PackageManager.GET_META_DATA);
            m_versionName = pInfo.versionName;
            m_versionCode = pInfo.versionCode;
        } catch (NameNotFoundException e) {
            e.printStackTrace();
        }
    }

}
